package com.sigerap.voucher.model.dao.jpa;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import com.sigerap.voucher.model.Voucher;
import com.sigerap.voucher.model.dao.VoucherDAO;
/**
 * 
 * @author Spirit-20121
 *
 */
public class JPAVoucherDAO implements VoucherDAO{
	
	private EntityManager em;


	public JPAVoucherDAO(EntityManager em) {
		this.em = em;
	}

	@Override
	public List<Voucher> findAll() {
		Query query = em.createQuery("Select p.nroOperacion From Voucher v");
		return query.getResultList();
	}

	@Override
	public Voucher insert(Voucher v) {
		em.persist(v);
		return v;
	}

}
